<!-- 编辑弹窗 -->
<template>
   <div class="ele-body">
    <el-form ref="form" :model="form" :rules="rules" label-width="100px" >
      <el-card  >  
        <div slot="header" class="clearfix" style="display: flex;justify-content:space-between;" >
          <div style="width: 50%;" >基础信息</div>
          <div style="width: 50%;display: flex;justify-content:end;" >
              <div style="width: 20%;color:var(--color-primary)" >制单人:{{ form.operatorName }}</div>
            </div>
        </div>  
        <el-row :gutter="24">
          <el-col :md="6" :sm="24">
            <el-form-item label="订单号:" prop="orderNo" style="width:100%">
              <el-input v-model="form.orderNo" :disabled="this.isUpdate==2" placeholder="请输入订单号" />
            </el-form-item>
          </el-col>    
          <el-col :md="6" :sm="24">
            <el-form-item label="客户名称:" prop="customerId">
              <el-select :disabled="this.isUpdate==2"  v-model="form.customerId" filterable clearable placeholder="请选择客户" style="width:100%" >
                <el-option  v-for="item in customerDatas" :key="item.id" :label="item.name" :value="item.id"/>
            </el-select>
            </el-form-item>
          </el-col>
          <el-col :md="6" :sm="24" >
            <el-form-item label="订单日期:"  prop="orderDate">
              <el-date-picker :disabled="this.isUpdate==2" v-model="form.orderDate" type="date" placeholder="请输入订单日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width:100%"  />
            </el-form-item>
          </el-col>
          <el-col :md="6" :sm="24">
            <el-form-item label="币种:" prop="currencyId">
              <el-select  :disabled="this.isUpdate==2" v-model="form.currencyId" filterable placeholder="请选择币种" style="width:100%" @change="changeCurrencyRate" >
                <el-option  v-for="item in currencyDatas" :key="item.id" :label="item.name" :value="item.id"/>
            </el-select>
            </el-form-item>
          </el-col>
          <el-col :md="6" :sm="24">
            <el-form-item label="汇率:" prop="rate">
              <el-input v-model="form.rate" placeholder="请输入汇率"  @change="setRate" />
            </el-form-item>
          </el-col>
          <el-col :md="6" :sm="24">
            <el-form-item label="发货仓库:" >
              <el-select  v-model="form.warehouseId" filterable clearable placeholder="请选择发货仓库" style="width:100%" >
                <el-option v-for="item in wareHouseDatas" :key="item.id" :label="item.name" :value="item.id"/>
            </el-select>
            </el-form-item>
          </el-col>
          <el-col :md="12" :sm="24" >
            <el-form-item label="备注:"  >
              <el-input :rows="1"
                  clearable
                  type="textarea"
                  :maxlength="200"
                  v-model="form.remark"
                  placeholder="请输入备注说明" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
      <el-card  style="margin-top: 10px">
        <div slot="header" class="clearfix" style="display: flex;justify-content:space-between;" >
          <div style="width: 8%;" >产品明细</div>
          <div style="width: 92%;display: flex;justify-content:start;" >
            <div style="width: 100%;color:var(--color-primary)" > 
              <el-button type="primary" class="ele-btn-icon" icon="el-icon-plus"  style="width: 10%;" @click="OpenProductList" v-permission="'SaleOrder_Product_Add'"  >选择产品 </el-button>
              <!-- <el-button type="primary" class="ele-btn-icon" icon="el-icon-plus"  style="width: 10%;" @click="addItemRow"  >新增产品明细 </el-button> -->
            </div>
          </div>
        </div> 
        <el-table :data="form.items" ref="items"  :border="true" style="width: 100%"  :height="tableHeight" :full-height="tableFullHeight"  show-summary :summary-method="getSummaries"  :cell-style="cellStyle">
          <el-table-column type="index" width="50" align="center" label="序号" fixed='left' />
          <el-table-column label="批次号" align="center"  prop="batchNo" sortable  width="150" v-if="this.batchNo" >
            <template slot-scope="{ row }">
              <el-tag v-if="form.currRec.status == 5" type="success" size="medium">{{ row.batchNo }}</el-tag>
              <el-tag v-else-if="form.currRec.status == 1"  type="danger" size="medium">{{ row.batchNo }}</el-tag>
              <el-tag v-else  type="primary" size="medium">{{ row.batchNo }}</el-tag>
            </template>
          </el-table-column>
          <el-table-column label="产品编号"  prop="productCode" sortable  align="center"  width="150">
            <template slot-scope="{ row }">
              <el-form-item label-width="10" style="margin-bottom:0;" >
                <span  >{{ row.productCode }}</span> 
              </el-form-item>
            </template>
            <!-- <template slot-scope="{ row , $index }">
              <el-form-item label-width="10" style="margin-bottom:0;" :prop="'items.'+ $index+'.productCode'" :rules="itemRules.productCode"  >
                <span v-show="row.deliveryQty>0" >{{ row.productCode }}</span> 
                <el-select v-show="row.deliveryQty==0"   filterable v-model="row.productCode" placeholder="请选择产品编号" class="ele-fluid" @change="changeproductcode(row,$index)" >
                  <el-option    v-for="(item, index) in productDatas" :key="index" :label="item.code" :value="item.code">
                    <span style="float: left">{{ item.code }}/{{ item.name }}</span>
                    <span style="float: right; color: #8492a6; font-size: 13px">{{ item.wareHouseDesc }}</span>
                  </el-option>
                </el-select>
              </el-form-item>
            </template> -->
          </el-table-column>
          <el-table-column label="产品名称" prop="productName" sortable   align="center"  width="150">
            <template slot-scope="{ row }">
              <el-form-item label-width="10" style="margin-bottom:0;"  >
                <span>{{ row.productName }}</span>
              </el-form-item>
            </template>
            <!-- <template slot-scope="{ row , $index}">
              <el-form-item label-width="10" style="margin-bottom:0;"  :prop="'items.'+ $index+'.productName'" :rules="itemRules.productName" >
                <span v-show="row.deliveryQty>0" >{{ row.productName }}</span>
                <el-select v-show="row.deliveryQty==0"  filterable v-model="row.productName" placeholder="请选择产品名称" class="ele-fluid" @change="changeproductname(row,$index)" >
                  <el-option v-for="(item, index) in productDatas" :key="index" :label="item.name" :value="item.name">
                    <span style="float: left">{{ item.code }}/{{ item.name }}</span>
                    <span style="float: right; color: #8492a6; font-size: 13px">{{ item.wareHouseDesc }}</span>
                  </el-option>
                </el-select>
              </el-form-item>
            </template> -->
          </el-table-column>
          <el-table-column label="规格" align="center"  width="100">
            <template slot-scope="{ row }">
              <span>{{ row.spc }}</span>
            </template>
          </el-table-column>
          <el-table-column label="单位" align="center"  prop="unitDesc" sortable   width="80">
              <template slot-scope="{ row }">
                <span>{{ row.unitDesc }}</span>
              </template>
          </el-table-column>
          <el-table-column label="数量" align="center" prop="qty" sortable  width="100">
            <template slot-scope="{row,$index}">
              <el-form-item label-width="10" style="margin-bottom:0;" :prop="'items.'+ $index+'.qty'" :rules="itemRules.qty" >
                <el-input  v-model="row.qty"  placeholder="请输入数量" @change="setAmount(row,$index)"  @keyup.native="row.qty = row.qty.replace(/[^\d.]/g,'');
                  row.qty = row.qty.replace(/\.{2,}/g,'.');
                  row.qty = row.qty.replace(/^\./g,'');
                  row.qty = row.qty.replace('.','$#$').replace(/\./g,'').replace('$#$','.');
                  row.qty = row.qty.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');" />
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column label="可用数量" align="center" sortable width="140">
            <template slot-scope="{ row }">
              <span>{{ row.useQty }}</span>
            </template>
          </el-table-column>
          <el-table-column label="已发货数量" align="center"   prop="deliveryQty" sortable width="140">
            <template slot-scope="{ row }">
              <span>{{ row.deliveryQty }}</span>
            </template>
          </el-table-column>
          <el-table-column label="单价" align="center"  prop="price" sortable width="120">
              <template slot-scope="{row,$index}">
                <el-form-item label-width="10" style="margin-bottom:0;"  :prop="'items.'+ $index+'.price'" :rules="itemRules.price">
                  <el-input  v-model="row.price"  placeholder="请输入单价"  @change="setAmount(row,$index)" @keyup.native="row.price = row.price.replace(/[^\d.]/g,'');
                  row.price = row.price.replace(/\.{2,}/g,'.');
                  row.price = row.price.replace(/^\./g,'');
                  row.price = row.price.replace('.','$#$').replace(/\./g,'').replace('$#$','.');
                  row.price = row.price.replace(/^(\-)*(\d+)\.(\d\d\d\d).*$/,'$1$2.$3');" />
                </el-form-item>
              </template>
          </el-table-column>
          <el-table-column label="金额" align="center" prop="amount" sortable  width="140">
            <template slot-scope="{ row ,$index}">
              <!-- <span>{{ row.amount }}</span> -->
              <el-form-item label-width="10" style="margin-bottom:0;"  :prop="'items.'+ $index+'.amount'" :rules="itemRules.amount">
                  <el-input  v-model="row.amount"  placeholder="请输入金额" @change="setOrderAmount"  @keyup.native="row.amount = row.amount.replace(/[^\d.]/g,'');
                  row.amount = row.amount.replace(/\.{2,}/g,'.');
                  row.amount = row.amount.replace(/^\./g,'');
                  row.amount = row.amount.replace('.','$#$').replace(/\./g,'').replace('$#$','.');
                  row.amount = row.amount.replace(/^(\-)*(\d+)\.(\d\d\d\d).*$/,'$1$2.$3');" />
                </el-form-item>
            </template>
          </el-table-column>
          <el-table-column label="单价(￥)" align="center" prop="priceCn" sortable   width="120">
            <template slot-scope="{ row }">
              <span>{{ row.priceCn }}</span>
            </template>
          </el-table-column>
          <el-table-column label="金额(￥)" align="center" prop="amountCn" sortable  width="140">
            <template slot-scope="{ row }">
              <span>{{ row.amountCn }}</span>
            </template>
          </el-table-column>
          <el-table-column label="发货仓库" align="center" prop="deliveryWareHouseId" sortable width="150" >
            <template slot-scope="{ row ,$index }">
              <el-form-item label-width="10" style="margin-bottom:0;"  :prop="'items.'+ $index+'.deliveryWareHouseId'" :rules="itemRules.deliveryWareHouseId">
                <el-select  filterable v-model="row.deliveryWareHouseId" placeholder="请选择发货仓库" class="ele-fluid" @change="changewarehouse(row)" >
                  <el-option v-for="item in wareHouseDatas" :key="item.id" :label="item.name" :value="item.id" />
                </el-select>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column label="行备注" align="center" width="150">
            <template slot-scope="{ row }">
              <el-input  v-model="row.remarks" placeholder="请输入行备注" />
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center"  width="80" :resizable="false" v-if="form.status!=5" fixed='right' >
            <template slot-scope="{ row , $index}">
              <span class="ele-action">
                <el-link v-permission="'SaleOrder_Product_Delete'"  icon="el-icon-delete" type="danger" :underline="false" @click="remove(row, $index)" >删除</el-link>
              </span>
            </template>
          </el-table-column>
        </el-table>
      </el-card>
      <el-card  style="margin-top: 10px">
        <div slot="header" class="clearfix" style="display: flex;justify-content:space-between;" >
          <div style="width: 8%;" >预收款</div>
          <div style="width: 92%;display: flex;justify-content:start;" >
            <div style="width: 100%;color:var(--color-primary)" > 
              <el-button type="primary" class="ele-btn-icon" icon="el-icon-plus"  style="width: 10%;" @click="OpenPrereviceItemList" v-permission="'SaleOrder_PreList_Add'"  >选择预收款</el-button>
            </div>
          </div>
        </div> 
        <el-table :data="form.prerevices" ref="prerevices"  :border="true" style="width: 100%"   :height="tableHeightPre" :full-height="tableFullHeightPre"  show-summary :summary-method="getSummariesPre"  :cell-style="cellStylePre">
          <el-table-column type="index" width="50" align="center" label="序号" fixed='left' />
          <el-table-column label="批次号" align="center"   v-if="this.batchNo">
            <template slot-scope="{ row }">
              <span>{{ row.batchNo }}</span>
            </template>
          </el-table-column>
          <el-table-column label="日期"   align="center"  :formatter="dateFormat" >
          </el-table-column>
          <el-table-column label="金额"   align="center" >
            <template slot-scope="{ row }">
              <el-form-item label-width="10" style="margin-bottom:0;" >
                <span>{{ row.amount }}</span>
              </el-form-item>
            </template>
          </el-table-column>
          <el-table-column label="币种" align="center"  width="100">
            <template slot-scope="{ row }">
              <span>{{ row.currencyDesc }}</span>
            </template>
          </el-table-column>
          <el-table-column label="收款账户" align="center"  >
              <template slot-scope="{ row }">
                <span>{{ row.bankAccountDesc }}</span>
              </template>
          </el-table-column>
          <el-table-column label="客户名称" align="center" >
            <template slot-scope="{ row }">
              <span>{{ row.customerName }}</span>
            </template>
          </el-table-column>
          <el-table-column label="单号" align="center" >
            <template slot-scope="{ row }">
              <span>{{ row.preNum }}</span>
            </template>
          </el-table-column>
          <el-table-column label="备注" align="center" width="160" prop="remark">
          </el-table-column>
          <el-table-column label="操作" align="center" width="100" :resizable="false" v-if="form.status!=5"  fixed='right' >
            <template slot-scope="{ row , $index}">
              <span class="ele-action">
                <el-link v-permission="'SaleOrder_PreList_Delete'"   icon="el-icon-delete" type="danger" :underline="false" @click="removePre(row, $index)" >删除</el-link>
              </span>
            </template>
          </el-table-column>
        </el-table>
      </el-card>
      <el-card shadow="never"> 
      </el-card>
      <div class="ele-dailog-bottom" >
        <div class="left" style="display: flex;width: 63% ;">
          <el-form-item label="订单金额:" style="margin-top: 20px;margin-left: -10px;">
            <span class="moneycolor moneyxh" >{{ form.currRec.orderAmount }}</span>
          </el-form-item>
          <el-form-item label="优惠金额:" style="margin-top: 20px;" label-width="80px">
            <el-input  v-model="form.currRec.disAmount"  placeholder="请输入优惠金额" @change="setRecAmount" style="width:100px;border:0" @keyup.native="form.currRec.disAmount = form.currRec.disAmount.replace(/[^\d.]/g,'');
                    form.currRec.disAmount = form.currRec.disAmount.replace(/\.{2,}/g,'.');
                    form.currRec.disAmount = form.currRec.disAmount.replace(/^\./g,'');
                    form.currRec.disAmount = form.currRec.disAmount.replace('.','$#$').replace(/\./g,'').replace('$#$','.');
                    form.currRec.disAmount = form.currRec.disAmount.replace(/^(\-)*(\d+)\.(\d\d\d\d).*$/,'$1$2.$3');" ></el-input>  
            <span v-show="this.form.status==15" class="moneycolor moneyxh">{{ form.currRec.disAmount }}</span>
          </el-form-item>
          <el-form-item label="收款账户:" style="margin-top: 20px;" prop="bankAccountId" label-width="82px">
            <el-select  v-model="form.bankAccountId" filterable clearable placeholder="请选择收款账户" style="width:100px"  @change="changeBank" @clear="changeBank" >
              <el-option v-for="item in bankAccountDatas" :key="item.id" :label="item.name" :value="item.id"/>
            </el-select>
          </el-form-item>
          <el-form-item label="收款金额:" style="margin-top: 20px;" prop="recAmount" label-width="82px">
            <el-input  v-model="form.currRec.recAmount"  placeholder="请输入收款金额" @change="checkAmount" @blur="checkAmount"  style="width:100px" @keyup.native="form.currRec.recAmount = form.currRec.recAmount.replace(/[^\d.]/g,'');
              form.currRec.recAmount = form.currRec.recAmount.replace(/\.{2,}/g,'.');
              form.currRec.recAmount = form.currRec.recAmount.replace(/^\./g,'');
              form.currRec.recAmount = form.currRec.recAmount.replace('.','$#$').replace(/\./g,'').replace('$#$','.');
              form.currRec.recAmount = form.currRec.recAmount.replace(/^(\-)*(\d+)\.(\d\d\d\d).*$/,'$1$2.$3');" >
            </el-input>
          </el-form-item>
          <el-form-item label="预收款:" style="margin-top: 20px;"  label-width="60px">
              <el-input  v-model="form.currRec.preAmount" disabled  placeholder="请输入预收款" @change="checkAmount"  style="width:90px" @keyup.native="form.currRec.preAmount = form.currRec.preAmount.replace(/[^\d.]/g,'');
                  form.currRec.preAmount = form.currRec.preAmount.replace(/\.{2,}/g,'.');
                  form.currRec.preAmount = form.currRec.preAmount.replace(/^\./g,'');
                  form.currRec.preAmount = form.currRec.preAmount.replace('.','$#$').replace(/\./g,'').replace('$#$','.');
                  form.currRec.preAmount = form.currRec.preAmount.replace(/^(\-)*(\d+)\.(\d\d\d\d).*$/,'$1$2.$3');" ></el-input> 
            </el-form-item>
        </div>
        <div class="right" style="display: flex;width: 20%;">
          <el-form-item style="margin-top: 20px" label-width="1px">
            <el-button type="primary" v-show=" form.status!=5 && form.status!=3 && form.currRec.status!=5 && form.currRec.status!=3" :loading="loading"  @click="save" v-permission="'SaleOrder_Save'" >挂单</el-button>
            <!-- <el-button type="info" @click="print"  v-show="form.status>=0">打印</el-button> -->
            <el-button  @click="handleClose">关闭</el-button>
          </el-form-item>
        </div>
      </div>
    </el-form>
    <!-- 编辑弹窗 -->
    <productList :visible.sync="showProductList"  @callback="reloadItemList"/>

    <prereviceitemList :data="current" :visible.sync="showPrereviceItemList"  @callback="reloadPrereviceItemList"/>
  </div>
  </template>
  <script>
   import { printHtml } from 'ele-admin';
   import { getUser } from '@/utils/user-util';
   import moment from 'moment';
   import upload from "@/components/UpLoad/index.js";
   import productList from '../components/product-list.vue';
   import prereviceitemList from '../components/prereviceitem-list.vue';
   import { GetAllAccount } from '@/api/usermanager/accountmanager';
   import { GetAllBackAccount } from '@/api/basicdatamanager/bankaccount';
   import { QueryCustomerPageList } from '@/api/basicdatamanager/customer';
   import { GetAllWarehouse } from '@/api/basicdatamanager/warehousemanager';
   import { QueryAllChildDictViewByCode } from '@/api/systemmanager/dictmanager';
   import { QueryModelByScurrencyId } from '@/api/basicdatamanager/ratemanager';
   import { GetAllBSupplier} from '@/api/basicdatamanager/supplier';
   import { QueryStockByProductIdAndWareHouseId} from '@/api/inventory/stock';
   import { QueryProductByStockCondition } from '@/api/basicdatamanager/productmanager';
   import { AddSaleorder, UpdateSaleorder,QuerySaleorderById,PrintSaleOrderById,QuerySaleorderByIdandBactNo} from '@/api/businesshandling/saleordermanager';
   import { QueryCommissionPageList,QueryCommissionByProductTypeId,QueryCommissionBySaleQty} from '@/api/basicdatamanager/commissionplan';
   import { removePageTab, reloadPageTab,setPageTabTitle } from '@/utils/page-tab-util';



    export default {
      name: 'SaleOrderEdit',
      props: {
        // 弹窗是否打开
        visible: Boolean,
        // 修改回显的数据
        data: Object,
        // 按钮索引
        btnIndex:String,
      },
      mixins: [upload],
      components: {productList,prereviceitemList},
      data() {
        return {
          // 表单数据
          form: {operatorId:'',orderDate:'',items:[],currRec:{orderAmount:0,disAmount:0,preAmount:0,recAmount:null,actAmount:0,rate:0,orderAmountCn:0,disAmountCn:0,preAmountCn:0,recAmountCn:0,actAmountCn:0,useQty:0}},
          fixedHeight:true,
          // 表单验证规则
          rules: {
            orderNo: [{required: true,message: '请输入订单号',trigger: 'blur'}],
            customerId: [{required: true,message: '请选择客户',trigger: 'blur'}],
            deliveryDate: [{required: true,message: '请输入交货日期',trigger: 'blur'}],
            currencyId: [{required: true,message: '请选择币种',trigger: 'blur'}],
            rate: [{required: true,message: '请输入汇率',trigger: 'blur'}],
            warehouseId: [{required: true,message: '请输入发货仓库',trigger: 'blur'}],
            orderDate: [{required: true,message: '请输入制单日期',trigger: 'blur'}],
            // bankAccountId:[{required: true,message: '请选择收款账户',trigger: 'blur'}],
            // recAmount:[{required: true,message: '请输入收款金额',trigger: 'blur'}],
            bankAccountId:null,
            recAmount:null,
          },
          itemRules: {
            
            qty: [{required: true,message: '请输入数量',trigger: 'blur'}],
            price: [{required: true,message: '请输入单价',trigger: 'blur'}],
            productCode:[{required: true,message: '请输入产品编号',trigger: 'blur'}],
            productName:[{required: true,message: '请输入产品名称',trigger: 'blur'}],
            commissionId:[{required: true,message: '请选择提成方案',trigger: 'blur'}],
            deliveryWareHouseId: [{required: true,message: '请输入发货仓库',trigger: 'blur'}],
          },
          batchNo:'',
          current:null,
          isShow:false,
          // 提交状态
          loading: false,
          // 是否是修改
          isUpdate: 1,
          saleorderId:'',
          showPrereviceItemList:false,
          showProductList:false,
          defaultDate:new Date(),
          unitDatas:[],
          productDatas:[],
          accountDatas:[],
          currencyDatas:[],
          wareHouseDatas:[],
          customerDatas:[],
          commissionDatas:[],
          bankAccountDatas:[],
          computeDirection:2,//默认奈拉
        };
      },
      computed: {
        // 表格高度
        tableHeight() {
          var fh = this.fixedHeight ? 'calc(100vh - 350px)' : void 0;

          return fh;
        },
        // 表格全屏时高度
        tableFullHeight() {
          var fh =  this.fixedHeight ? 'calc(100vh - 280px)' : null;

          return fh;
        },

        // 表格高度
        tableHeightPre() {
          var fh = this.fixedHeight ? 'calc(100vh - 500px)' : void 0;

          return fh;
        },
        // 表格全屏时高度
        tableFullHeightPre() {
          var fh =  this.fixedHeight ? 'calc(100vh - 450px)' : null;

          return fh;
        },
      },
      //初始化数据
      mounted(){

        if(this.isUpdate == 2 || this.isUpdate == 3){
          this.setData(this.saleorderId);
        }else if(this.isUpdate == 1){
          this.$refs['form'].clearValidate();
          this.form={operatorId:'',orderDate:'',bankAccountId:'',items:[],currRec:{orderAmount:0,disAmount:0,preAmount:0,recAmount:null,actAmount:0,rate:0,orderAmountCn:0,disAmountCn:0,preAmountCn:0,recAmountCn:0,actAmountCn:0,surplusDeliveryQtyTotal:0}};
          let currentUser = getUser();
          this.$set(this.form,'orderDate',this.defaultDate);
          this.$set(this.form,'operatorId',currentUser.accountId);
          this.$set(this.form,'operatorName',currentUser.accountName);
          this.setDefaultCurreny();
        }
      },
      created(){
        this.initData();
        this.batchNo = this.$route.query.batchNo;
        this.isUpdate = this.$route.query.isUpdate;
        this.saleorderId = this.$route.query.saleorderId;
        if(this.isUpdate == 1)  setPageTabTitle('添加销售订单');
        if(this.isUpdate == 2)  setPageTabTitle('编辑销售订单');
      },
      methods: {

        dateFormat(row,column,cellValue){
          return moment(cellValue).format("YYYY-MM-DD");
        },

        /* 初始化数据 */
        async initData(){

          

          GetAllAccount().then((res)=>{
            this.accountDatas = [];
            this.accountDatas = res;
          });

          GetAllBSupplier().then((res)=>{
            this.supplierDatas = [];
            this.supplierDatas = res;
          });

          GetAllWarehouse().then((res)=>{
            this.wareHouseDatas = [];
            this.wareHouseDatas = res;
          });

          GetAllBackAccount().then((res)=>{
            this.bankAccountDatas = [];
            this.bankAccountDatas = res;
          });

          QueryAllChildDictViewByCode(this.Constant.C_HB).then((res)=>{
            this.currencyDatas = [];
            this.currencyDatas = res;
          });

          QueryAllChildDictViewByCode(this.Constant.C_DW).then((res)=>{
            this.unitDatas = [];
            this.unitDatas = res;
          });

          let params = {
              pageindex: 1,
              pagesize: 10000,
              conditions: [],
              orderBys: [{ sort: "createDate", order: 1, }],
            };


          params.conditions.push({
            key:"deleted",
            operator: 0,
            value: 0,
          });

          let result = await QueryCustomerPageList(params);
          this.customerDatas=[];
          this.customerDatas = result.items;


          let commissions = await QueryCommissionPageList(params);
          this.commissionDatas=[];
          this.commissionDatas = commissions.items;

          params.conditions.push({ key:"status",operator: 0,value: 0,})
          let stocks =await QueryProductByStockCondition(params)
          this.productDatas = [];
          this.productDatas = stocks.items;

        },

        /* 保存编辑 */
        save() {
            this.$refs['form'].clearValidate();
            this.rules.recAmount = null;
            this.rules.bankAccountId = null;
            if(this.form.bankAccountId && !this.form.currRec.recAmount){
              this.rules.recAmount = [{required: true,message: '请输入收款金额',trigger: 'blur'}];
            }

            if(!this.form.bankAccountId && this.form.currRec.recAmount){
              this.rules.bankAccountId = [{required: true,message: '请选择收款账户',trigger: 'blur'}];
            }

          //校验必填信息
          this.$refs['form'].validate((valid) => {
            if (!valid) {return false;}

            
            if(this.form.currRec.recAmount && this.form.rate){
              this.form.currRec.recAmountCn = this.computeDirection == 1?  (this.form.currRec.recAmount*this.form.rate).toFixed(4):(this.form.currRec.recAmount/this.form.rate).toFixed(4);
            }

            if(this.form.currRec.actAmount && this.form.rate){
              this.form.currRec.actAmountCn = this.computeDirection == 1?  (this.form.currRec.actAmount*this.form.rate).toFixed(4):(this.form.currRec.actAmount/this.form.rate).toFixed(4);
            }

            if(this.form.currRec.preAmount && this.form.rate){
              this.form.currRec.preAmountCn = this.computeDirection == 1?  (this.form.currRec.preAmount*this.form.rate).toFixed(4):(this.form.currRec.preAmount/this.form.rate).toFixed(4);
            }

            if(this.form.rate){
              this.form.currRec.rate = this.form.rate
            }

            if(this.form.orderDate){
              this.form.currRec.orderDate = this.form.orderDate
            }

            this.form.currRec.orderId = this.form.id;

            
            this.form.currRec.surplusDeliveryQtyTotal = this.form.currRec.qtyTotal;   
            if(this.form.items){
              this.form.items.map((item)=>{
                item.surplusDeliveryQty = item.qty;
              })
            }
          

            const saveOrUpdate = (this.isUpdate == 2 || this.isUpdate == 3)? UpdateSaleorder : AddSaleorder;

            this.loading = true;
            saveOrUpdate(this.form)
            .then((msg) => {
              this.loading = false;
              this.$message.success(msg);
              this.updateVisible();
            
            })
            .catch((e) => {
              this.loading = false;
              this.$message.error(e.message);
            });
          });
        },

        setData(id){
          if(this.isUpdate == 2 || this.isUpdate == 1){

            QuerySaleorderById(id)
              .then((res) => {
                this.form = res; 
                this.form.items =[];
                this.form.prerevices = [];
                this.form.currRec = {orderAmount:0,disAmount:0,preAmount:0,recAmount:0,actAmount:0,rate:0,orderAmountCn:0,disAmountCn:0,preAmountCn:0,recAmountCn:0,actAmountCn:0,bankAccountId:''}
              
                this.changeCurrencyRate(res.currencyId);

                this.$nextTick(() => {
                  this.$refs.items.doLayout();
                });
            });
          }else  if(this.isUpdate == 3){
            var param = { orderId:id,batchNo:this.batchNo};
            QuerySaleorderByIdandBactNo(param)
              .then((res) => {
                this.form = res; 
                this.changeCurrencyRate(res.currencyId);

                this.$nextTick(() => {
                  this.$refs.items.doLayout();
                });
            });
          }
        },

        OpenProductList(){
          this.showProductList =true;
        },

        OpenPrereviceItemList(){
          if(this.form.orderNo){
            this.showPrereviceItemList =true;
            this.current = {preNum:this.form.orderNo,customerId:this.form.customerId}
          }else{
            this.$message.info("请输入订单号");
            return ;
          }
          
        },
        
        reloadItemList(orderData){

          if(this.form.items==null || this.form.items ==undefined){
            this.form.items = [];
          }

          orderData.map((item)=>{
            this.form.items.push({
              orderId:this.form.id,
              productId:item.id,
              qty:0,
              price:0,
              unitId:item.unitId,
              amount:0,
              rate:this.form.rate,
              currencyId:this.form.currencyId,
              priceCn:0,
              amountCn:0,
              deliveryQty:0,
              useQty:item.useQty?item.useQty:0,
              deliveryWareHouseId:item.wareHouseId?item.wareHouseId:this.form.warehouseId,
              commissionId:item.commissionId,
              commissionType:item.commissionType,
              commissionName:item.commissionName,
              commissionMethod:item.commissionMethod,
              scale:item.scale,
              commissionAmount:0,
              commissionAmountCn:0,
              costPrice:item.purPrice,
              productCode:item.code,
              productName:item.name,
              productTypeId:item.typeId,
              spc:item.spc,
              unitDesc:item.unitDesc,
              remarks:item.remarks,
            })
          });

          this.$nextTick(() => {
            this.$refs.items.doLayout();
          });

        },

        reloadPrereviceItemList(prereviceItemData){
          this.form.prerevices = [];
          prereviceItemData.map((item)=>{
            this.form.prerevices.push({
              orderId:this.form.id,
              // batchNo:item.id,
              prereviceId:item.id,
              reviceDate:item.reviceDate,
              amount:item.amount,
              currencyId:item.currencyId,
              currencyDesc:item.currencyDesc,
              bankAccountId:item.bankAccountId,
              bankAccountDesc:item.bankAccountDesc,
              customerId:item.customerId,
              customerName:item.customerName,
              preNum:item.preNum,
              remark:item.remark,
            })
          });

          this.$nextTick(() => {
            this.$refs.prerevices.doLayout();
          });

          this.form.currRec.preAmount = this.form.prerevices.reduce((pre,cur)=> { return parseFloat(pre?pre:0)  + parseFloat(cur.amount?cur.amount:0)  },0);

          this.setRecAmount();
        },

        //设置金额
        setAmount(row,index){

          if(row.price && row.qty){
              let q = parseFloat(row.qty);
              let p = parseFloat(row.price);
              row.amount = (p * q).toFixed(4);
          }

          if(row.amount && this.form.rate){
              let r = parseFloat(this.form.rate);
              let a = parseFloat(row.amount);
              row.amountCn = this.computeDirection ==1?(a * r).toFixed(4):(a / r).toFixed(4);
          }

          if(row.amountCn && row.qty){
              let rq = parseFloat(row.qty);
              let ra = parseFloat(row.amountCn);
              row.priceCn =this.computeDirection ==1? (ra * rq).toFixed(4):(ra / rq).toFixed(4);
          }

          if(row.amount && row.scale){
              let s = parseFloat(row.scale);
              let a = parseFloat(row.amount);
              row.commissionAmount = ((s * a)/100).toFixed(4);
          }

          if(row.commissionAmount && this.form.rate){
            row.commissionAmountCn =this.computeDirection ==1?(row.commissionAmount*this.form.rate).toFixed(4): (row.commissionAmount/this.form.rate).toFixed(4);
          }
          
          /*剩余发货数 =  销售数量*/
          // row.surplusDeliveryQty = row.qty;
         
          //设置提成金额信息
          this.changeCommissionType(row);

          //设置汇总信息
          this.setCommissionAmountTotal();
        },

        setOrderAmount(){
          
          this.form.currRec.orderAmount = this.form.items.reduce((pre,cur)=> { return parseFloat(pre?pre:0)  + parseFloat(cur.amount)  },0);
          if(this.form.rate){
            this.form.currRec.orderAmountCn= this.computeDirection ==1? (this.form.currRec.orderAmount*this.form.rate).toFixed(4):(this.form.currRec.orderAmount/this.form.rate).toFixed(4);
          }
        },

        //汇率发生变化时,对应产品明细的相关数据发生变化
        setRate(){

          this.$refs.items.data.map((item)=>{

            item.amount = (item.price && item.qty)?(item.qty * item.price).toFixed(4):0;
            item.amountCn = 0;
            if(item.amount && this.form.rate){
              item.amountCn = this.computeDirection == 1?(item.amount * parseFloat(this.form.rate)).toFixed(4):(item.amount / parseFloat(this.form.rate)).toFixed(4);
            }
            item.priceCn = (item.amountCn && item.qty)?(item.amountCn / item.qty).toFixed(4):0;

            //设置提成信息
            this.changeCommissionType(item);
          })

          this.setCommissionAmountTotal();
        },

        /* 删除 */
        remove(_row, index) {
          // this.form.items.splice(index, 1);
          this.form.items = this.form.items.filter((c)=>{return c.productCode !=_row.productCode && c.productName != _row.productName});
          this.setCommissionAmountTotal();
        },

        /* 删除 */
        removePre(_row, index) {
          this.form.prerevices.splice(index, 1);
          this.setPreAmount();
        },

        // 选择提成类型
        changeCommissionType(row){

          row.scale = 0;
          row.commissionId = '';
          row.commissionAmount = 0;
          row.commissionAmountCn = 0;

          if((row.commissionType===0 || row.commissionType===1) && this.form.currencyId ){
            let commission = this.commissionDatas.find((d)=>{
              return d.commissionType == row.commissionType && d.currencyId == this.form.currencyId
            });

            if(commission){
             
              // 按产品类型提成 
              if(commission.commissionType == 0 ){

                //同一产品类型才能提成
                if(row.productTypeId == commission.productTypeId){

                  // 按数量 1
                  if(commission.commissionMethod == 1){

                    row.scale = commission.scale;
                    row.commissionId =commission.id;
                    row.commissionAmount = ((row.qty? parseFloat(row.qty):0) * parseFloat(commission.scale));
                    row.commissionAmountCn = this.computeDirection ==1 ? ((row.commissionAmount)*parseFloat(this.form.rate)).toFixed(4):((row.commissionAmount)/parseFloat(this.form.rate)).toFixed(4);
                  }

                  //按比例 2
                  if(commission.commissionMethod == 2){
                    row.scale = commission.scale;
                    row.commissionId =commission.id;
                    row.commissionAmount = (((row.amount? parseFloat(row.amount):0) * parseFloat(commission.scale))/100).toFixed(4);;
                    row.commissionAmountCn = this.computeDirection ==1 ? ((row.commissionAmount)*parseFloat(this.form.rate)).toFixed(4):((row.commissionAmount)/parseFloat(this.form.rate)).toFixed(4);
                  }
                }
              }

              // 按销售数量提成 
              if(commission.commissionType == 1 ){

                // 按数量 1
                if(commission.commissionMethod == 1){

                  row.scale = commission.scale;
                  row.commissionId =commission.id;
                  row.commissionAmount = ((row.qty? parseFloat(row.qty):0) * parseFloat(commission.scale));
                  row.commissionAmountCn = this.computeDirection ==1 ? ((row.commissionAmount)*parseFloat(this.form.rate)).toFixed(4):((row.commissionAmount)/parseFloat(this.form.rate)).toFixed(4);
                }

                //按比例 2
                if(commission.commissionMethod == 2){
                  row.scale = commission.scale;
                  row.commissionId =commission.id;
                  row.commissionAmount = (((row.amount? parseFloat(row.amount):0) * parseFloat(commission.scale))/100).toFixed(4);;
                  row.commissionAmountCn = this.computeDirection ==1 ? ((row.commissionAmount)*parseFloat(this.form.rate)).toFixed(4):((row.commissionAmount)/parseFloat(this.form.rate)).toFixed(4);
                }
              }

            }
          }
        },

        // 清除提成类型
        clear(row){
          row.scale = 0;
          row.commissionAmount = 0;
          row.commissionAmountCn = 0;

          this.changeCommissionType(row);
          this.setCommissionAmountTotal();
        },


        //设置汇总信息
        setCommissionAmountTotal(){
          this.form.currRec.qtyTotal = 0;
          // this.form.recAmount = 0;
          // this.form.recAmountCn = 0;
          this.form.currRec.actAmount = 0;
          this.form.currRec.disAmount = 0;
          this.form.currRec.disAmountCn = 0;
          this.form.currRec.orderAmount = 0;
          this.form.currRec.orderAmountCn = 0;
          this.form.currRec.commissionAmount = 0;
          this.form.currRec.commissionAmountCn = 0;
          this.form.currRec.deliveryQtyTotal = 0;

          if(this.form.items!=null && this.form.items!=undefined && this.form.items.length>0){
            this.form.currRec.qtyTotal = this.form.items.reduce((pre,cur)=> { return parseFloat(pre?pre:0)  + parseFloat(cur.qty)  },0);
            this.form.currRec.orderAmount = this.form.items.reduce((pre,cur)=> { return parseFloat(pre?pre:0)  + parseFloat(cur.amount)  },0);
            this.form.currRec.commissionAmount = this.form.items.reduce((pre,cur)=> { return parseFloat(pre?pre:0)  + parseFloat(cur.commissionAmount?cur.commissionAmount:0)  },0);
            this.form.currRec.commissionAmountCn = this.form.items.reduce((pre,cur)=> { return parseFloat(pre?pre:0)  + parseFloat(cur.commissionAmountCn?cur.commissionAmountCn:0)  },0);
            this.form.currRec.deliveryQtyTotal = this.form.items.reduce((pre,cur)=> { return parseFloat(pre?pre:0)  + parseFloat(cur.deliveryQty?cur.deliveryQty:0)  },0);
            this.form.currRec.useQty = this.form.items.reduce((pre,cur)=> { return parseFloat(pre?pre:0)  + parseFloat(cur.useQty?cur.useQty:0)  },0);
           
            this.form.currRec.useQty =this.form.currRec.useQty.toFixed(2);
            this.form.currRec.qtyTotal =this.form.currRec.qtyTotal.toFixed(2);
            this.form.currRec.orderAmount = this.form.currRec.orderAmount.toFixed(4);
            this.form.currRec.deliveryQtyTotal =this.form.currRec.deliveryQtyTotal.toFixed(2);
            this.form.currRec.commissionAmount = this.form.currRec.commissionAmount.toFixed(4);
            this.form.currRec.commissionAmountCn = this.form.currRec.commissionAmountCn.toFixed(4);

            this.form.currRec.orderAmountCn= this.computeDirection ==1? (this.form.currRec.orderAmount*this.form.rate).toFixed(4):(this.form.currRec.orderAmount/this.form.rate).toFixed(4);
            this.setRecAmount();
          }
        },

        //统计预收款
        setPreAmount(){
          this.form.currRec.preAmount = 0;
          if(this.form.prerevices!=null && this.form.prerevices!=undefined && this.form.prerevices.length>0){
            this.form.currRec.preAmount = this.form.prerevices.reduce((pre,cur)=> { return parseFloat(pre?pre:0)  + parseFloat(cur.amount?cur.amount:0)  },0);
          }
        },

        setRecAmount(){
          // this.form.recAmount = (this.form.orderAmount - this.form.disAmount).toFixed(4);
          this.form.currRec.recAmountCn =this.computeDirection ==1? (this.form.currRec.recAmount * this.form.rate).toFixed(4): (this.form.currRec.recAmount / this.form.rate).toFixed(4);
          if(this.form.currRec.disAmount){
            this.form.currRec.disAmountCn = this.computeDirection ==1?(this.form.currRec.disAmount*this.form.rate).toFixed(4):(this.form.currRec.disAmount / this.form.rate).toFixed(4);
          }
          this.checkAmount();
          
        },

        checkAmount(){

          this.form.currRec.actAmount =  parseFloat(this.form.currRec.orderAmount?this.form.currRec.orderAmount:0) - parseFloat(this.form.currRec.preAmount?this.form.currRec.preAmount:0) -  parseFloat(this.form.currRec.recAmount?this.form.currRec.recAmount:0)-  parseFloat(this.form.currRec.disAmount?this.form.currRec.disAmount:0)
          this.form.currRec.actAmountCn =  this.computeDirection ==1? (this.form.currRec.actAmount*this.form.rate).toFixed(4):(this.form.currRec.actAmount/this.form.rate).toFixed(4);
        },

        changeBank(val){

          let bank = this.bankAccountDatas.find((b)=>{ return b.id == val});
          if(bank){
            this.form.currRec.bankAccount = bank.name;
          }
        },

        //设置币种
        setDefaultCurreny(){
          // C-HB03
          QueryAllChildDictViewByCode(this.Constant.C_HB).then((d)=>{

            d.map((item)=>{
              if(item.code == 'C-HB03'){
              this.form.currencyId = item.id;
              this.changeCurrencyRate(item.id);
            }
            })
          });
        },

        /* 更新visible */
        updateVisible(value) {
          removePageTab({ key: this.$route.path });
          reloadPageTab({ fullPath: '/businesshandling/saleordermanager' });
        },

        handleClose() {
          removePageTab({ key: this.$route.path });
          this.$router.push('/businesshandling/saleordermanager');
        },

        /* 选择币种 */
        changeCurrencyRate(val){

          if(this.isUpdate !=3 ) this.$set(this.form,'rate',1); //新增时默认汇率
          QueryModelByScurrencyId(val).then((res)=>{
            if(res){
              this.computeDirection = res.computeDirection;
              if(this.isUpdate !=3 )this.$set(this.form,'rate',res.rate);//新增时默认汇率
            }
            this.setRate();
          });
        },

        // 打印
        print(){
          PrintSaleOrderById(this.form.id).then((data)=>{
            const pWindow = printHtml({
                html: data, // 要打印的内容
                // style: '<style>span { color: red; }</style>',  // 页面样式
                // title: '', // 页面标题，浏览器打印设置显示页眉会显示页面标题
                horizontal: true, // 是否横向打印
                blank: true, // 是否打开新页面打印
                close: true, // 如果是打开新页面，打印完是否关闭
                print: true, // 如果是打开新窗口是否自动打印
                iePreview: true, // 是否兼容 ie 打印预览
                loading: true, // 是否显示 loading
                before: () => { // 打印开始的回调
                },
                done: () => { // 打印完成的回调
                },
                margin: 0, // 页间距
                header: '', // 页眉 html
                footer: '' // 页脚 html
            });
          });
        },

        /* 合计 */
        getSummaries(param){
          const sums = [];
          sums[0] = '合计' ;
          const { columns, data } = param;
          columns.forEach((column, index) => {
            
            if(this.batchNo){
              
              if(index ==6){
                sums[index] =  Number(this.form.currRec.qtyTotal).toFixed(2);
              }else if(index ==7){
                var useqty = this.form.items.reduce((pre,cur)=> { return parseFloat(pre?pre:0)  + parseFloat(cur.useQty?cur.useQty:0)  },0);
                sums[index] = useqty.toFixed(2);
              }else if(index ==8){
                sums[index] = Number(this.form.currRec.deliveryQtyTotal).toFixed(2);
              }else if(index ==10){
                sums[index] = Number(this.form.currRec.orderAmount).toFixed(4);
              }else if(index ==12){
                sums[index] = Number(this.form.currRec.orderAmountCn).toFixed(4);
              }

            }else{

              if(index ==5){
                sums[index] =  Number(this.form.currRec.qtyTotal).toFixed(2);
              }else if(index ==6){
                var useqty = this.form.items.reduce((pre,cur)=> { return parseFloat(pre?pre:0)  + parseFloat(cur.useQty?cur.useQty:0)  },0);
                sums[index] = useqty.toFixed(2);
              }else if(index ==7){
                sums[index] = Number(this.form.currRec.deliveryQtyTotal).toFixed(2);
              }else if(index ==9){
                sums[index] = Number(this.form.currRec.orderAmount).toFixed(4);
              }else if(index ==11){
                sums[index] = Number(this.form.currRec.orderAmountCn).toFixed(4);
              }


            }


            // else if(index ==14){
            //   sums[index] = Number(this.form.currRec.commissionAmount).toFixed(4);
            // }else if(index ==15){
            //   sums[index] = Number(this.form.currRec.commissionAmountCn).toFixed(4);
            // }
          });

          this.$nextTick(() => {
            this.$refs.items.doLayout();
          });
          return sums;
        },

        /* 样式 */
        cellStyle(param){
          const { row, column, rowIndex, columnIndex } = param;
          if(columnIndex==6||columnIndex==7||columnIndex==9||columnIndex==10||columnIndex==11||columnIndex==15||columnIndex==16){
            return{
              color:''
            }
          }
        },

        /* 合计 */
        getSummariesPre(param){
          const sums = [];
          sums[0] = '合计' ;
          const { columns, data } = param;
          columns.forEach((column, index) => {
            if(index ==3){
              sums[index] =  Number(this.form.currRec.preAmount).toFixed(4);
            }
          });

          this.$nextTick(() => {
            this.$refs.prerevices.doLayout();
          });
          return sums;
        },

        /* 样式 */
        cellStylePre(param){
          const { row, column, rowIndex, columnIndex } = param;
          if(columnIndex==3){
            return{
              color:''
            }
          }
        },

        /*选择仓库*/
        changewarehouse(row){
          
          let param = {wareHouseId:row.deliveryWareHouseId,productId:row.productId};
          QueryStockByProductIdAndWareHouseId(param).then((res)=>{
            row.useQty = 0;
            if(res){ row.useQty = res.useQty; }
          });
        },

        /*选择产品编号*/
        changeproductcode(row,index){
          
          var product = this.productDatas.find((item)=>{
            return item.code == row.productCode;
          });

          if(product){
            this.form.items[index].spc = product.spc;
            this.form.items[index].useQty = product.useQty;
            this.form.items[index].productId = product.id;
            this.form.items[index].productName = product.name;
            this.form.items[index].productTypeId = product.typeId;
            this.form.items[index].commissionType= product.commissionType;
            this.form.items[index].commissionMethod = product.commissionMethod;
            this.form.items[index].deliveryWareHouseId = product.wareHouseId;

            var unit = this.unitDatas.find((item)=>{
              return item.id == product.unitId;
            });

            if(unit){
              this.form.items[index].unitDesc = unit.name;
              this.form.items[index].unitId = product.unitId;
            }

            this.changeCommissionType(row)
            this.setCommissionAmountTotal()
          }
          
        },

        /*选择产品名称*/
        changeproductname(row,index){
          
          var product = this.productDatas.find((item)=>{
            return item.name == row.productName;
          });

          if(product){
            this.form.items[index].spc = product.spc;
            this.form.items[index].useQty = product.useQty;
            this.form.items[index].productId = product.id;
            this.form.items[index].productCode = product.code;
            this.form.items[index].productName = product.name;
            this.form.items[index].productTypeId = product.typeId;
            this.form.items[index].commissionType= product.commissionType;
            this.form.items[index].commissionMethod = product.commissionMethod;

            this.form.items[index].deliveryWareHouseId = product.wareHouseId;

            var unit = this.unitDatas.find((item)=>{
              return item.id == product.unitId;
            });

            if(unit){
              this.form.items[index].unitDesc = unit.name;
              this.form.items[index].unitId = product.unitId;
            }

            this.changeCommissionType(row)
            this.setCommissionAmountTotal()
          }
        },

        addItemRow(){
          this.form.items.push({
              batchNo:this.form.items.length>0?this.form.items[0].batchNo:'',
              orderId:this.form.id,
              productId:'',
              qty:0,
              price:0,
              unitId:'',
              amount:0,
              rate:this.form.rate,
              currencyId:this.form.currencyId,
              priceCn:0,
              amountCn:0,
              deliveryQty:0,
              useQty:0,
              deliveryWareHouseId:this.form.warehouseId,
              commissionId:'',
              commissionType:'',
              commissionName:'',
              commissionMethod:'',
              scale:0,
              commissionAmount:0,
              commissionAmountCn:0,
              costPrice:0,
              productCode:'',
              productName:'',
              productTypeId:'',
              spc:'',
              unitDesc:'',
              remarks:'',
          })
        },
    },
     
      /* 监听visible属性变化 */
      watch: {
        visible(visible) {
         
          // if (visible) {
          //   if (this.data && this.data.id) {
          //     //赋值this.form
          //     this.setData(this.data.id);
          //     this.isUpdate = this.data.id !=null && this.data.id !=undefined;
          //   } else {
          //     this.form={operatorId:'',orderDate:'',orderAmount:0,disAmount:0,recAmount:0};
          //     this.isUpdate = false;
          //     let currentUser = getUser();
          //     this.$set(this.form,'orderDate',this.defaultDate);
          //     this.$set(this.form,'operatorId',currentUser.accountId);
          //     this.$set(this.form,'operatorName',currentUser.accountName);
          //     this.setDefaultCurreny();
          //   }
          // } else {
          //     this.$refs['form'].clearValidate();
          //     this.form = {operatorId:'',orderDate:'',orderAmount:0,disAmount:0,recAmount:0};
          //     let currentUser = getUser();
          //     this.$set(this.form,'orderDate',this.defaultDate);
          //     this.$set(this.form,'operatorId',currentUser.accountId);
          //     this.$set(this.form,'operatorName',currentUser.accountName);
          //     this.setDefaultCurreny();
          // }
        },
       
      }
    };
  </script>
  <style lang="scss" scoped>
  /*总计字体颜色
  ::v-deep .el-table__footer-wrapper tbody td {
     color: var(--color-primary);
     cursor: pointer;
   }*/
 </style>